package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.SchoolLinkman;
import cn.wolfcode.crm.mapper.SchoolLinkmanMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ISchoolLinkmanService;
import cn.wolfcode.crm.util.PageResult;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Collections;
import java.util.List;

@Service
public class SchoolLinkmanServiceImpl implements ISchoolLinkmanService {

    @Autowired
    private SchoolLinkmanMapper mapper;

    public void insert(SchoolLinkman record) {
        mapper.insert(record);
    }

    public void updateByPrimaryKey(SchoolLinkman record) {
        mapper.updateByPrimaryKey(record);
    }




    public PageResult query(QueryObject qo) {
        int total = mapper.query4Count(qo);
        if (total > 0) {
            return new PageResult(total, mapper.query4List(qo));
        }
        return new PageResult(total, Collections.EMPTY_LIST);
    }

    public SchoolLinkman selectById(Long id) {
        return mapper.selectByPrimaryKey(id);
    }


    public HSSFWorkbook exportXls(QueryObject qo) {
        return null;
    }


    public void importXls(MultipartFile file) throws IOException {

    }

    public void delete(Long id) {
        mapper.deleteByPrimaryKey(id);
    }

    public List<SchoolLinkman> selectAll() {
        return mapper.selectAll();
    }

    public List<SchoolLinkman> selectBySchoolName(Long schoolId) {
        return mapper.selectBySchoolName(schoolId);
    }
}
